package com.seckill.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seckill.framework.mybatisplus.WrapperParse;
import com.seckill.user.mapper.UserMapper;
import com.seckill.user.pojo.User;
import com.seckill.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 作者
 * @since 2022-03-14
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 分页查询
     * @param user
     * @param page
     * @param size
     * @return
     */
    @Override
    public Page<User> findPage(User user, int page, int size) {
        //分页
        IPage<User> iPage = new Page<User>(page,size);
        //条件构造
        QueryWrapper<User> wrapper = WrapperParse.simple(user);
        Page<User> pageInfo = (Page<User>) userMapper.selectPage(iPage, wrapper);
        return pageInfo;
    }
}
